import http from '../http';
interface LoginOptions {
    phone?: string;
    password?: string;
    base64?: string;
}

//发送短信验证码
export const sendCode = (phone: string) => {
    return http.post('/csy/sendCode', {
        phone,
    });
};


export const register1 = (option: LoginOptions) => {
    return http.post('/csy/register', {
        phone: option.phone,
        password: option.password,
    })
}

//登录
export const login1 = (option: LoginOptions) => {
    return http.post('/csy/login', {
        phone: option.phone,
        password: option.password,
    })
}

//获取二维码
export const getQrcode = () => {
    return http.post('/csy/createQRCode')
}

//实现人脸识别
export const faceRecognition = (option: LoginOptions) => {
    return http.post('/csy/faceLogin', {
        base64: option.base64,
    })
}

//实现人脸绑定手机号
export const faceBindPhone = (option: LoginOptions) => {
    return http.post('/csy/faceBind', {
        phone: option.phone,
        base64: option.base64,
    })
}

//验证码登录
export const codeLogin = (option: LoginOptions) => {
    return http.post('/csy/yzmLogin', {
        phone: option.phone,
    })
}



interface RegisterOptions {
    year: string,
    object: string,
    startTime: string,
    endTime: string,
    name1: string,
    contet: string,
    timer: string,
    array: [string],
    jianTime: string
}

//添加发起讯前检查
export const addCheck = (option: RegisterOptions) => {
    return http.post('/csy/setdingTable', {
        year: option.year,
        object: option.object,
        startTime: option.startTime,
        endTime: option.endTime,
        name: option.name1,
        contet: option.contet,
        timer: option.timer,
        array: option.array,
        jianTime: option.jianTime
    })
}

interface NoticeOptions {
    bian: string,
    name: string,
    content: string,
    timer: string,
    rusult?: string
}
//添加检查通知单
export const addNotice = (option: NoticeOptions) => {
    return http.post('/csy/setNoticeTable', {
        bian: option.bian,
        name: option.name,
        contet: option.content,
        timer: option.timer,

    })
}
//添加结果报告
export const addResult = (option: NoticeOptions) => {
    return http.post('/csy/setRusult', {
        bian: option.bian,
        name: option.name,
        contet: option.content,
        timer: option.timer,
        rusult: option.rusult
    })
}

//获取检查通知单
export const getNotice = (option: any) => {
    return http.get('/csy/getdingTable', {
        params: {
            page: option.page,
        }
    })
}

//国阳云短信接口
export const sendMsg = (option: any) => {
    return http.post('/csy/send-sms', {
        mobile: option.phone,
    })
}

//修改密码
export const changePassword = (option: LoginOptions) => {
    return http.post('/csy/updatePassword', {
        phone: option.phone,
        password: option.password,
    })
}

interface NoticeOptions1 {
    title: string,
    year: string,
    name: string,
    time: string,
    rusult: string,
}

//添加特别检查
export const addSpecial = (option: NoticeOptions1) => {
    return http.post('/csy/setSpecial', {
        year: option.year,
        title: option.title,
        name: option.name,
        time: option.time,
        rusult: option.rusult,
    })
}

//获取特别检查
export const getSpecial = () => {
    return http.get('/csy/getSpecial')
}

interface NoticeOptions2 {
    projectName: string,
    repairReason: string,
    selectedDevice: string,
    plannedCompletionTime: string,
    assignedPersonnel: string,
    taskIssuer: string,
    fileList: any[],
}

//添加日常维修
export const addDaily = (option: NoticeOptions2) => {
    return http.post('/csy/setDaily', {
        name: option.projectName,
        yuan: option.repairReason,
        finish: option.plannedCompletionTime,
        zhiding: option.assignedPersonnel,
        time: option.plannedCompletionTime,
        person: option.taskIssuer,
        file: option.fileList,
    })
}

//获取日常维修
// 导出一个函数getDaily，用于获取每日数据
export const getDaily = () => {
    // 使用http.get方法，发送GET请求，请求地址为'/csy/getDaily'
    return http.get('/csy/getDaily')
}

interface NoticeOptions3 {
    daily: string,
    fileList?: any, //完成照片
    rusult: string, // 维修结果
    time: string,  // 维修时间
    name: string, // 维修人
    shebei: string, // 维修设备
    buwei: string,  // 维修部位
    content: string,    // 维修内容
}

//添加维修结果
export const addResult1 = (option: NoticeOptions3) => {
    return http.post('/csy/setRepair', {
        daily: option.daily,
        file: option.fileList,
        rusult: option.rusult,
        time: option.time,
        name: option.name,
        shebei: option.shebei,
        buwei: option.buwei,
        content: option.content,
    })
}

//获取单一维修结果
export const getSingleResult = (option: any) => {
    return http.post('/csy/getRepair', {
        daily: option.daily,
    })
}
//修改单一维修结果
export const updateSingleResult = (option: any) => {
    return http.post('/csy/setDailyState', {
        id: option.daily,
        state: option.state,
    })
}
//删除
export const deleteSingleResult = (option: any) => {
    return http.post('/csy/delDaily', {
        id: option.daily,
    })
}

//删除特别检查
export const deleteSpecial = (option: any) => {
    return http.post('/csy/delSpecial', {
        id: option.id,
    })
}

//删除定期检查
export const deleteRegular = (option: any) => {
    return http.post('/csy/delDing', {
        id: option.id,
    })
}

//滑块登录
export const captcha1 = () => {
    return http.post('/csy/captcha')
}